package com.xiaowenxiong.service;

import com.xiaowenxiong.dao.ScMapper;
import com.xiaowenxiong.entity.Sc;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by 15c on 2017/6/6.
 */
@Service("Sc")
public class ScServiceImpl  implements ScService{
    @Autowired
    ScMapper scMapper;

    /**
     * 修改成绩
     * @param sc
     * @return
     */
    @Override
    public int updateGrade(Sc sc) {
        return scMapper.updateByPrimaryKeySelective(sc);
    }

    /**
     * 获得学生总学分
     * @param sno
     * @return
     */
    @Override
    public Double getAllCcredit(String sno) {
        return scMapper.selectCcredit(sno);
    }

    /**
     * 用于添加学生成绩
     * @param sc
     * @return
     */
    @Override
    public int addGrade(Sc sc) {
        return scMapper.insertSelective(sc);
    }

    /**
     * 删除一个用户的所有成绩记录
     * @param sno
     * @return
     */
    @Override
    public int deleteGrade(String sno) {
        return scMapper.delete(sno);
    }

    /**
     * 删除一门学生成绩
     * @param sc
     * @return
     */
    @Override
    public int deleteOneGrade(Sc sc) {
        return scMapper.deleteByPrimaryKey(sc);
    }
}
